<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .count{
            display: inline-block;
            width: 200px;
            height: 200px;
            background: pink;
            color: black;
            line-height: 200px;
            text-align: center;
            font-size: 20px;
            border-radius: 50%;
        }
    </style>
</head>
<body>
    <div id="app">
        <v-a></v-a>
        <br>
        <v-b></v-b>
        <br>
        <v-c></v-c>
    </div>
</body>
<script src="./js/vue.js"></script>
<script>
    // 总线模式
    Vue.prototype.$bus = new Vue()

    Vue.config.productionTip = false;
    var vm = new Vue({
        el:"#app",
        components:{
            "v-a":{
                template:"<span @click='clickFn'>{{msg}}</span>",
                data(){
                    return {
                        msg:"v-a"
                    }
                },
                methods:{
                    clickFn(){
                        this.$bus.$emit("change",this.msg)
                    }
                },
                mounted(){
                    this.$bus.$on("change",(msg)=>{this.msg = msg})
                }
            },
            "v-b":{
                template:"<span @click='clickFn'>{{msg}}</span>",
                data(){
                    return {
                        msg:"v-b"
                    }
                },
                methods:{
                    clickFn(){
                        this.$bus.$emit("change",this.msg)
                    }
                },
                mounted(){
                    this.$bus.$on("change",(msg)=>{this.msg = msg})
                }
            },
            "v-c":{
                template:"<span @click='clickFn'>{{msg}}</span>",
                data(){
                    return {
                        msg:"v-c"
                    }
                },
                methods:{
                    clickFn(){
                        this.$bus.$emit("change",this.msg)
                    }
                },
                mounted(){
                    this.$bus.$on("change",(msg)=>{this.msg = msg})
                }
            }
        }
    })



</script>
</html>